import request from "@/utils/request";

const admin = "/admin/acl/user";

export const reqUserName = (page, limit, val) => {
  if (val) {
    return request.get(`/admin/acl/user/${page}/${limit}?username=${val}`);
  } else {
    return request.get(`/admin/acl/user/${page}/${limit}`);
  }
};

export const reqAddUser = (data) => {
  if (data.id) {
    console.log('id');
    return request.put("/admin/acl/user/update", data);
  } else {
    console.log(123);
    return request.post("/admin/acl/user/save", data);
  }
};

export const reqdetele = (id) => {
  return request.delete(`/admin/acl/user/remove/${id}`);
};
export const reqUpdate = (data) => {
  return request.put("/admin/acl/user/update", data);
};

export const reqRoles = (userId) => {
  return request.get(`${admin}/toAssign/${userId}`);
};

export const reqDoAssign = (userId,roleId)=>{
    return request({
        url:`${admin}/doAssign`,
        method:'post',
        params:{
            userId,
            roleId
        }
    })
}
